﻿@inherits BlazorStrap.Shared.Components.Common.BSPopoverBase
@namespace BlazorStrap.V4

@if (Content == null && Target != null)
{
    <BlazorStrap.Shared.InternalComponents.Error Name="BSPopover">
        The <strong>Content</strong> RenderFragment is required.
    </BlazorStrap.Shared.InternalComponents.Error>

    return;
}
@if (ShouldRenderContent)
{
    <CascadingValue Value="this">
        @if (IsDropdown)
        {
            if (IsNavItemList)
            {
                <ul class="@ClassBuilder" style="@Style" @attributes="Attributes" @ref="MyRef" data-popper-placement="@Placement.Name().ToDashSeperated()" data-blazorstrap="@DataId" data-bs-popper="blazorstrap">
                    @if (Content != null)
                    {
                        @Content(this)
                    }
                </ul>
            }
            else
            {
                <div class="@ClassBuilder" style="@Style" @attributes="Attributes" @ref="MyRef" data-popper-placement="@Placement.Name().ToDashSeperated()" data-blazorstrap="@DataId" data-bs-popper="blazorstrap">
                    @if (Content != null)
                    {
                        @Content(this)
                    }
                </div>
            }
        }
        else
        {
            <div class="@ClassBuilder" style="@Style" @attributes="Attributes" @ref="MyRef" data-popper-placement="@Placement.Name().ToDashSeperated()" data-blazorstrap="@DataId" data-bs-popper="blazorstrap">

                <div class="arrow"></div>
                @if (Header != null)
                {
                    <div class="@HeaderClass">
                        @Header
                    </div>
                }
                <div class="popover-body">
                    @if (Content != null)
                    {
                        @Content(this)
                    }
                </div>

            </div>
        }
    </CascadingValue>
}